/**
* 弹窗组件，使用： this.$store.dispatch('setModal',{visible:true，modalId:'modlaId'}); 注意this指向的上下文环境，有时候是写self或其它
*/
<template>
  <transition name="slide-fade">
    <div v-if="modal.visible && modal.modalId=='reliveModal'" class="modal" id="reliveModal" tabindex="-1" @click.stop.prevent="modalHide">
      <div class="modal-dialog" @click.stop.prevent>
        <div class="modal-content">
          <img src="~assets/images/tankuang-l@2x.png" class="img-responsive">
          <img src="~assets/images/close@2x.png" data-dismiss="modal" class="img-close"  @click.stop.prevent="modalHide">
          <div class="oxhead">
            <img src="http://dl.app.gtja.com/nrng/shareimages/oxhead/haixiu.png">
          </div>
          <div class="wrapper">
            <h4>确认复活？</h4>
            <div class="">复活需要给小的<span>80</span>个君元宝</div>
            <p>大王，你即将穿越回原始状态。<span>你的持仓记录将被销毁，你的积分数据和其他订阅关系小的仍然为你保留</span>，复活后还会送您100万炒股资产，小的等你回来哦~</p>
            <button type="button" class="btn btn-lg btn-agree" @click.stop.prevent="relive">朕确定</button>
            <button type="button" class="btn btn-lg btn-reject" @click.stop.prevent="modalHide">且慢</button>
          </div>
        </div>
      </div>
    </div>
  </transition>
</template>

<script>
  import BaseModal from 'components/modal/BaseModal'
  import RemoteDAO from 'common/remoteDAO'
  import LocalDAO from 'common/localDAO'

  export default {
    data () {
      return {
        userCode:LocalDAO.getUserCode()
      }
    },
    extends:BaseModal,
    methods:{
      relive(){
        // 埋点
        var object = {};
        object.usercode = this.userCode;
        TDAPP.onEvent("5002", "", object);
        TDAPP.send();

        // 一键复活
        RemoteDAO.callUC12000109(this.userCode, "NRNG", "0004", (response) =>{
          if (Number(response.error) === 0) {
            this.$store.dispatch('setTip',{text:"一键复活成功"});
            setTimeout(() =>{
              document.body.scrollTop= 0;
              window.location.reload();
            }, 800);
          } else {
            this.$store.dispatch('setTip',{text:response.data});
          }
        });
      }
    }
  }
</script>

<style scoped>
  .slide-fade-enter-active,.slide-fade-leave-active{
    transition: all 0.3s ease;
  }
  .slide-fade-enter, .slide-fade-leave-active {
    transform: translate(0,-25%);
    opacity: 0;
  }
</style>
